package entity.movementbehavior;

import map.ViewArea;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Vector2f;

import entity.Entity;

public class MovementKeyboard extends MovementBehavior
{
	boolean sprint = false;
	
	public MovementKeyboard(Entity e, float s, float sprintS, float walkS)
	{
		super(e, s, sprintS, walkS);
	}
	
	public void getAction(Input input)
	{
		double rSpeedScale = speedScale;
		
		if (input.isKeyDown(Input.KEY_LSHIFT))
		{
			rSpeedScale = sprintSpeed;
		}
		
		else
		{
			rSpeedScale = speedScale;
		}
		
		//up
		if (input.isKeyDown(Input.KEY_W) && speed.y > -rSpeedScale)
		{
			speed.y -= accelScale;
		}
		
		//down
		else if (input.isKeyDown(Input.KEY_S) && speed.y < rSpeedScale)
		{
			speed.y += accelScale;
		}
		
		//left
		if (input.isKeyDown(Input.KEY_A) && speed.x > -rSpeedScale)
		{
			speed.x -= accelScale;
		}
		
		//right
		else if (input.isKeyDown(Input.KEY_D) && speed.x < rSpeedScale)
		{
			speed.x += accelScale;
		}	
	}
	
	public void update(GameContainer gc, ViewArea screen)
	{
		getAction(gc.getInput());
		resolveFriction();
		move(screen);
	}
	
	/*
	@Override
	public Vector2f calculateNextPosition(Vector2f currentPosition) 
	{
		return null;
	}*/

	
}
